import 'package:flutter/material.dart';
import 'package:flutter_quick/Interfaces/IM.dart';

class ContactItem extends StatelessWidget {
  ConversationItem conversationItem;

  ContactItem({
    Key? key,
    required this.conversationItem,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        Navigator.of(context).pushNamed('/chat', arguments: {});
      },
      child: Container(
        padding: EdgeInsets.only(left: 14),
        child: Row(
          children: [
            Container(
              height: 44,
              width: 44,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.all(
                  Radius.circular(4),
                ),
                image: DecorationImage(
                  image: NetworkImage(conversationItem.avatar),
                  fit: BoxFit.cover,
                ),
              ),
            ),
            Expanded(
              child: Container(
                padding:
                    EdgeInsets.only(left: 10, top: 10, bottom: 10, right: 14),
                decoration: BoxDecoration(
                  border: BorderDirectional(
                    bottom: BorderSide(
                      color: Color(0xfff1f1f1),
                    ),
                  ),
                ),
                child: Column(
                  children: [
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        // 标题
                        Text(
                          conversationItem.title,
                          style:
                              TextStyle(fontSize: 16, color: Color(0xff000000)),
                        ),
                        // 时间
                        Container(
                          width: 36,
                          child: Text(
                            '12:22',
                            style: TextStyle(
                                fontSize: 12, color: Color(0xffacacac)),
                          ),
                        )
                      ],
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        // 聊天内容
                        Expanded(
                          child: Text(
                            conversationItem.lastMsg,
                            maxLines: 1,
                            overflow: TextOverflow.ellipsis,
                            style: TextStyle(
                              fontSize: 14,
                              color: Color(0xffacacac),
                            ),
                          ),
                        ),
                        Container(
                          width: 36,
                          alignment: Alignment.centerRight,
                          child: Icon(
                            Icons.media_bluetooth_off,
                            size: 12,
                            color: Color(0xffacacac),
                          ),
                        )
                      ],
                    )
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
